package cn.caskm.souvenirshopsystem.controller.api;

import cn.caskm.souvenirshopsystem.domain.Result;
import cn.caskm.souvenirshopsystem.domain.po.GoodsCategory;
import cn.caskm.souvenirshopsystem.service.GoodsCategoryService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/category")
@RequiredArgsConstructor
public class CategoryController {

    private final GoodsCategoryService goodsCategoryService;

    @GetMapping("/getAll")
    public Result<List<GoodsCategory>> getAll() {
        List<GoodsCategory> list = goodsCategoryService.lambdaQuery()
                .orderByAsc(GoodsCategory::getOrderNum)
                .list();
        return Result.success(list);
    }

}
